home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 015a / qw12inst.zip / HEX.TEC < prev    next >
Text File  |  1991-03-14  |  8KB  |  153 lines

  1. ID:HX Hexadecimal Numbers and QEMM
  2. Quarterdeck Technical Note #190
  3. by Vernon Balbert
  4.  
  5. Q:   Why are these numbers mixed up with these letters and what   
  6.      do they mean?
  7.  
  8. A:   These numbers and letters are part of a numbering system     
  9.      that is used by computers.
  10.  
  11.      Computers don't count the way people do.  People use
  12. decimal, or base 10 for counting and we use the numbers 0-9
  13. giving us 10 different symbols for counting.  Computers, on the
  14. other hand, use binary, a number system that uses just zeros and
  15. ones.  So, a typical binary number might look like this:
  16.  
  17.                        1001011011010010
  18.  
  19.      Kind of confusing, huh? Well, even to programmers, these
  20. numbers are confusing.  People just don't work well with binary. 
  21. Computers do.  Binary numbers can be translated to decimal quite
  22. easily, but they just aren't neat.  For instance, if you use an
  23. eight digit binary number, you can count up to 255.  Well, this
  24. has three decimal numbers and multiples of 256 (counting 0) is
  25. just not very neat or easy.  However, there is a different way of
  26. counting that is widely used by computer people.  This is called
  27. HEXADECIMAL.  Hexadecimal is base 16.  What this means is that if
  28. you were to start counting from 0, you would continue up to some
  29. single digit that would represent 15.  And that's where the
  30. letters come from.  Hexadecimal numbers go like this:
  31.  
  32.                0 1 2 3 4 5 6 7 8 9 A B C D E F
  33.  
  34.       Well, part of that looks normal, at least until the 9.  The
  35. A translates as 10, the B as 11 on up until the F is equal to 15. 
  36. After F, you tack on a 1 at the beginning of the number just like
  37. we do so you would get 10.  And, yes, 10 plus 10 equal 20.  Since
  38. 10 in hexa- decimal is equal to 16 in decimal, it would be
  39. logical to assume that if 16+16=32 then 20 hexadecimal equals 32
  40. decimal.  Rest assured, it does.  Often, to tell the difference
  41. between hexadecimal and decimal numbers, programmers will use H
  42. at the end of the number to say that it is hexadecimal, i.e. 
  43. 10H.  Now, if you have 8 binary numbers, you can count either to
  44. 256, or to FFH.  (Remember, the H stands for hexadecimal.) This
  45. means that you can count in multiples of 4 binary digits with one
  46. hexadecimal digit.  For instance:
  47.  
  48.                  10010110=96H=150 base 10
  49.  
  50.       Now, you might ask, why use multiples of 4 binary digits?
  51. Well, the answer is really quite simple.  Computer people like to
  52. group binary numbers in groups of eight.  A hexadecimal number
  53. can represent 4 binary digits.  Each number is called a bit and
  54. each group of eight bits is a byte.  And computer memory is
  55. measured in bytes.  Each byte can represent one character such as
  56. the letter "Q" or the number "3".  Your hard disk is measured in
  57. megabytes, or millions of bytes.  So,  hexadecimal is a number
  58. system that both computers and humans can work with easily. 
  59. Actually, computers don't work with hexadecimal, but most
  60. programs that work with hexadecimal numbers have routines that
  61. translate the hexadecimal numbers to binary for the computer
  62. because it's so easy; simply convert each hex digit into the
  63. appropriate 4 binary digits.  By the way, hexadecimal is often
  64. referred to as "hex" for short.
  65.  
  66.      Okay, now we have to delve a little into the history of IBM
  67. PCs to understand the way you address memory.
  68.  
  69.      When IBM first came out with the PC, the Intel 8088
  70. processor was used.  The 8088 can access 1 megabyte of memory. 
  71. However, the chip only has 16 bit registers.  (A register is an
  72. internal memory loca- tion.) You can only count to 65535 with 16
  73. bits.  In order to access the 20 bits outside the microprocessor,
  74. an alternate method of ad- dressing memory was developed.  So,
  75. addresses had the following format:
  76.  
  77.                           ssss:oooo
  78.  
  79.      The first four hex digits (ssss) are the segment address. 
  80. The last four (oooo) are the offset address.  Together, these can
  81. address the entire 1 megabyte space of the 8088.  This is called
  82. relative addressing.  You never actually say the exact address
  83. that you are pointing at, just an address relative to a different
  84. position.  For instance, if you have an address such as
  85. 1234:2319, you would take 1234H, add a 0 to the end so it turns
  86. into 12340H and then add 2319H to it to get 14659H.
  87.  
  88.      When the 80286 came out, it had 24 address lines to address
  89. more than the 1 megabyte of memory available.  (24 address lines
  90. lets you address 16 megabytes of memory.) Additionally, the
  91. internal registers were enlarged to 24 bits so you didn't have to
  92. go through the segment and offset gyrations.  So, you could now
  93. use absolute addressing.  The address now takes this format:
  94.  
  95.                            XXXXXX
  96.  
  97.      Notice now, that there are 6 digits instead of two sets of 4
  98. when an 80286 is in "protected" mode (6 digit mode).  DOS,
  99. unfortunately, only understands segmented memory addressing which
  100. is in "real" mode.  Intel built in a "real" mode into the 80286
  101. and higher processors so that they would still understand
  102. relative addressing.  This difference is VERY important.  It is
  103. the main reason that you can't use exTENDed memory (only
  104. available in "protected" mode) to run DOS programs (which require
  105. "real" mode).  
  106.  
  107.      QEMM, QRAM and DESQview all observe the relative addressing
  108. scheme.  So, when you include or exclude areas of memory with
  109. QEMM, you use the segment address.  Typically, the only
  110. exclusions you will use involve the area above the 640K program
  111. space.  This is a 384K area of memory that is normally used by
  112. adapter cards and ROMs in your computer.  The address range of
  113. the lower 640K is 0000-9FFF.  Remem-ber, these are the segment
  114. addresses, not the offset addresses.  The area above 640K is the
  115. A000-FFFF range.
  116.  
  117. Here is a translation table so you can convert some common
  118. hexadecimal addresses into decimal and back.
  119.  
  120. Common way of    Decimal    Hexadecimal    Segment:Offset 
  121.  saying it
  122.  
  123.     1K             1024         400     0040:0000 or 0000:0400
  124.     2K             2048         800     0080:0000 or 0000:0800
  125.     4K             4096        1000     0100:0000 or 0000:1000
  126.     8K             8192        2000     0200:0000 or 0000:2000
  127.    16K            16384        4000     0400:0000 or 0000:4000
  128.    32K            32768        8000     0800:0000 or 0000:8000
  129.    64K            65536       10000           1000:0000
  130.   128K           131072       20000           2000:0000
  131.   256K           262144       40000           4000:0000
  132.   384K           393612       60000           6000:0000
  133.   512K           524288       80000           8000:0000 
  134.   640K           655350       A0000           A000:0000
  135.   704K           720896       B0000           B000:0000
  136.   736K           753664       B8000           B800:0000
  137.   768K           786432       C0000           C000:0000 
  138.   832K           851968       D0000           D000:0000
  139.   896K           917504       E0000           E000:0000
  140.   960K           983040       F0000           F000:0000
  141.  1024K          1048576      100000      1MB and beyond cannot
  142.                                          be addressed with the    
  143.                                          segment:offset method.
  144.  
  145. In summary, we see that hexadecimal (or hex, for short) is
  146. actually base 16, decimal is base 10 and binary is base 2.  Hex
  147. numbers go from 0 to F, decimal numbers go from 0 to 9 and binary
  148. go from 0 to 1.  Hex numbers are used to make it easier for
  149. people to work with numbers that the computer uses.
  150.  
  151.       Copyright (C) 1991 by Quarterdeck Office Systems
  152.             * * * E N D  O F  F I L E * * * 
  153.